import { mapGetters } from "vuex";
import dateFormat from "vux/src/tools/date/format.js";

import dataTimeFilter from "../../../common/dataTimeFilter/dataTimeFilter";
import template from "./statisticsTemplate";
const { render, staticRenderFns } = template;

export default {
  render,
  staticRenderFns,
  components: {
    dataTimeFilter,
  },
  data() {
    return {
      datePicker: false,
      obj: {},
      beginTime: dateFormat(new Date(), "YYYY-MM-DD"),
      endTime: dateFormat(new Date(), "YYYY-MM-DD"),
    };
  },
  computed: {},
  created() {
    this.resetAll();
  },
  methods: {
    pullingDown() {
      this._getOwmSelf();
    },
    pickHide(data) {
      this.datePicker = data;
    },
    getTime(data) {
      this.beginTime = data[0];
      this.endTime = data[1];
      this.datePicker = false;
      this._getOwmSelf(1);
    },
    resetAll() {
      this.beginTime = "";
      this.endTime = "";
      this._getOwmSelf(1);
    },
    _getOwmSelf(flag) {
      let vm = this;
      if (flag) {
        vm.$vux.loading.show();
      }
      let params = {};
      params.token = localStorage.getItem("token");
      params.start_time = vm.beginTime;
      params.end_time = vm.endTime;
      vm.$http
        .post(vm.urlRequest + "?m=api&c=user&a=myOneself", params)
        .then((res) => {
          if (res.status == 0) {
            vm.obj = res;
          } else {
            if (res.ret_msg && res.ret_msg != "") {
              vm.$vux.toast.show({
                text: res.ret_msg,
              });
            }
          }
          vm.$refs.scroll.forceUpdate(false);
          vm.$vux.loading.hide();
        })
        .catch((err) => {
          vm.$refs.scroll.forceUpdate(false);
          vm.$vux.loading.hide();
          console.log(err);
        });
    },
  },
};

// WEBPACK FOOTER //
// ./src/components/personalCenter/teamManagement/statistics/statistics.vue
